package ca.bcit.comp3910.model;

import java.io.Serializable;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;

/**
 * 
 * Timesheet row to store rows
 * 
 * @author Ivy Cheung, Stacy Mitchell
 * @version 2.0
 * 
 */
@SuppressWarnings("serial")
@Named
@ApplicationScoped
public class TimesheetRow implements Serializable {
    /**
     * project name
     */
    private Integer projectName;
    /**
     * work project
     */
    private String wP;
    /**
     * total hours
     */
    private double total;
    /**
     * saturday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double sat;
    /**
     * sunday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double sun;
    /**
     * monday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double mon;
    /**
     * tuesday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double tue;
    /**
     * wednesday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double wed;
    /**
     * thursday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double thu;
    /**
     * friday hours
     */
    @DecimalMin("0.0")
    @DecimalMax("24.0")
    @Digits(fraction = 1, integer = 2)
    private double fri;
    /**
     * notes
     */
    private String notes;
    /**
     * editable
     */
    private boolean editable;

    /**
     * Constructor to instantiate data
     */
    public TimesheetRow() {
        projectName = null;
        wP = "";
        total = 0;
        mon = 0;
        tue = 0;
        wed = 0;
        thu = 0;
        fri = 0;
        sat = 0;
        sun = 0;
        notes = "";
    }

    /**
     * Constructor for passing in variable to create a new object
     * 
     * @param projectName
     * @param wP
     * @param total
     * @param sat
     * @param sun
     * @param mon
     * @param tue
     * @param wed
     * @param thu
     * @param fri
     * @param notes
     */
    public TimesheetRow(Integer projectName, String wP, double sat, double sun, double mon, double tue, double wed,
            double thu, double fri, String notes) {
        this.projectName = projectName;
        this.wP = wP;
        total = sat + sun + mon + tue + wed + thu + fri;
        this.sat = sat;
        this.sun = sun;
        this.mon = mon;
        this.tue = tue;
        this.wed = wed;
        this.thu = thu;
        this.fri = fri;
        this.notes = notes;
    }

    /**
     * Get Project Name
     * 
     * @return project name
     */
    public Integer getProjectName() {
        return projectName;
    }

    /**
     * Set project name
     * 
     * @param projectName
     */
    public void setProjectName(Integer projectName) {
    	if (projectName == 0) {
    		this.projectName = null;
    	}
    	else {
    		this.projectName = projectName;    		
    	}        
    }

    /**
     * Get work project
     * 
     * @return work project
     */
    public String getwP() {
        return wP;
    }

    /**
     * Set work project
     * 
     * @param wP
     *            work project
     */
    public void setwP(String wP) {
        this.wP = wP;
    }

    /**
     * Get Total
     * 
     * @return sum of all work hours in a week
     */
    public double getTotal() {
        return sat + sun + mon + tue + wed + thu + fri;
    }

    /**
     * Get Saturday hours
     * 
     * @return saturday hours
     */
    public double getSat() {
        return sat;
    }

    /**
     * Set saturday hours
     * 
     * @param sat
     *            hours
     */
    public void setSat(double sat) {
        this.sat = sat;
    }

    /**
     * Get sunday hours
     * 
     * @return sun hours
     */
    public double getSun() {
        return sun;
    }

    /**
     * Set sunday hours
     * 
     * @param sun
     *            hours
     */
    public void setSun(double sun) {
        this.sun = sun;
    }

    /**
     * Get Monday hours
     * 
     * @return hours
     */
    public double getMon() {
        return mon;
    }

    /**
     * Set Monday hours
     * 
     * @param mon
     *            hours
     */
    public void setMon(double mon) {
        this.mon = mon;
    }

    /**
     * Get Tuesday hours
     * 
     * @return tues ours
     */
    public double getTue() {
        return tue;
    }

    /**
     * Set Tuesday hours
     * 
     * @param tue
     *            hrs
     */
    public void setTue(double tue) {
        this.tue = tue;
    }

    /**
     * Get Wednesday Hours
     * 
     * @return weds hours
     */
    public double getWed() {
        return wed;
    }

    /**
     * Set Wednesday hours
     * 
     * @param wed
     *            hours
     */
    public void setWed(double wed) {
        this.wed = wed;
    }

    /**
     * Get Thursday hours
     * 
     * @return Thursday hours
     */
    public double getThu() {
        return thu;
    }

    /**
     * Set Thursday Hours
     * 
     * @param thu
     *            hours
     */
    public void setThu(double thu) {
        this.thu = thu;
    }

    /**
     * Get Friday Hours
     * 
     * @return friday hours
     */
    public double getFri() {
        return fri;
    }

    /**
     * Set Friday Hours
     * 
     * @param fri
     *            hrs
     */
    public void setFri(double fri) {
        this.fri = fri;
    }

    /**
     * Get Notes
     * 
     * @return notes
     */
    public String getNotes() {
        return notes;
    }

    /**
     * Set Notes
     * 
     * @param notes
     */
    public void setNotes(String notes) {
        this.notes = notes;
    }

    /**
     * Is editable
     * 
     * @return editable
     */
    public boolean isEditable() {
        return editable;
    }

    /**
     * Set Editable
     * 
     * @param editable
     */
    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "TimesheetRow [projectName=" + projectName + ", wP=" + wP
                + ", total=" + total + ", sat=" + sat + ", sun=" + sun
                + ", mon=" + mon + ", tue=" + tue + ", wed=" + wed + ", thu="
                + thu + ", fri=" + fri + ", notes=" + notes + "]";
    }
}
